//
//  HttpRequestFactory.cpp
//  EZC_Library
//
//  Created by ellzu on 14-9-25.
//  Copyright (c) 2014年 ellzu. All rights reserved.
//

#include "HttpRequestFactory.h"
#include "HttpRequest_Curl.h"



using namespace EZHttp;


HttpRequestFactory* HttpRequestFactory::defaultFactory()
{
    static HttpRequestFactory *factory = 0;
    if (factory == 0) {
        factory = new HttpRequestFactory();
    }
    return factory;
}

HttpRequestFactory::HttpRequestFactory()
{
}

HttpRequestFactory::~HttpRequestFactory()
{
    
}
EZTallyTemplateAutoPtr<HttpRequest*> HttpRequestFactory::makeRequestAutoPtr()
{
    HttpRequest *request = allocRequest();
    EZTallyTemplateAutoPtr<HttpRequest*> ptr;
    ptr.Set(request);
    request->Release();
    return ptr;
}
HttpRequest* HttpRequestFactory::makeRequest()
{
    EZAutoreleasePoolManager *pools = EZAutoreleasePoolManager::DefaultManager();
    EZAutoreleasePool *pool =  pools->CurrentPool();
    if (pool==0) {
        return 0;
    }
    HttpRequest *request = allocRequest();
    request->AuroRelease();
    return request;
}

HttpRequest* HttpRequestFactory::allocRequest()
{
    HttpRequest_CURL *curl = new HttpRequest_CURL();
    HttpRequest *request = new HttpRequest(curl);
    curl->Release();
//    request->AuroRelease();
    return request;
}
